<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-07-10 17:50
 *
 * Version: 2.0
 */

namespace App\Modules\Employee\Repositories;


use App\Lib\Utilities;
use App\Models\UserRank;
use App\Modules\Employee\Validators\UserRankValidator;
use App\Modules\Order\Repositories\OrderRepository;
use App\Modules\Store\Repositories\StoreRepository;
use Flower\Core\Repository\Eloquent\BaseRepository;
use Illuminate\Support\Facades\DB;

class UserRankRepository extends BaseRepository
{
	public function model()
	{
		return UserRank::class;
	}

	public function validator()
	{
		return UserRankValidator::class;
	}

	public function add($requestData){
		DB::beginTransaction();
		$res =  $this->model->insert($requestData);
		$res ? DB::commit() : DB::rollBack();
		return $res;
	}

	/**
	 * 获取理发师排名
	 * @param $requestData
	 * @return mixed
	 */
	public function getUserRank($requestData){
		$date = isset($requestData['date']) ? $requestData['date'] : date('Y-m-d', time());
		return $this->model->where('user_id',$requestData['user_id'])->whereDate('created_at',$date)->first();
	}

}